Don't scan uncompressed_objects_dir if it doesn't exist
authorOwen W. Taylor <otaylor@fishsoup.net>
Wed, 11 Apr 2018 22:06:39 +0000 (18:06 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 12 Apr 2018 13:53:15 +0000 (13:53 +0000)
A newly created archive-mode repository won't have a uncompressed-objects-cache
directory, and uncompressed_objects_dir is -1 to flag that. The special meaning of
-1 meaning "cwd" for libglnx means that the current directory was scanned as
if it was an objects directory, producing unexpected results, especially if there
were any two-letter files/subdirs in the current directory.

Closes: #1537
Approved by: jlebon

src/libostree/ostree-repo-commit.c

index 37f832c8fc1847b6bd06ca13cf74d769b8d0b1e5..5fd979025b5f7df59dcab72c2f27aa48d3e1262a 100644 (file)
@@ -1438,7 +1438,8 @@ scan_loose_devino (OstreeRepo                     *self,
         return FALSE;
     }
 
-  if (self->mode == OSTREE_REPO_MODE_ARCHIVE)
+  if (self->mode == OSTREE_REPO_MODE_ARCHIVE &&
+      self->uncompressed_objects_dir_fd != -1)
     {
       if (!scan_one_loose_devino (self, self->uncompressed_objects_dir_fd, devino_cache,
                                   cancellable, error))